{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "def loadDataSet(filename, delim='\\t'):\n",
    "    '''\n",
    "    加载数据集\n",
    "    '''\n",
    "    dataArr = []\n",
    "    with open(filename) as fr:\n",
    "        for line in fr:\n",
    "            stringline = line.strip().split(delim)\n",
    "            dataline = list(map(float, stringline))\n",
    "            dataArr.append(dataline)\n",
    "    return np.mat(dataArr)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "def PCA(dataMat, topNfeat=9999999):\n",
    "    # 去平均值\n",
    "    meanVals = np.mean(dataMat, axis = 0)\n",
    "    meanRemoved = dataMat - meanVals\n",
    "    # np.cov()计算协方差，返回array\n",
    "    covMat = np.cov(meanRemoved, rowvar=0)\n",
    "    # 计算特征值与特征向量\n",
    "    eigVals, eigVects = np.linalg.eig(np.mat(covMat))\n",
    "    eigValInd = np.argsort(eigVals)\n",
    "    # 最大的topNfeat个向量\n",
    "    eigValInd = eigValInd[:-(topNfeat+1):-1]\n",
    "    redEigVects = eigVects[:,eigValInd]\n",
    "    # 新空间里降维后数据\n",
    "    lowDataMat = meanRemoved * redEigVects\n",
    "    print(np.shape(meanRemoved),np.shape(redEigVects),np.shape(lowDataMat))\n",
    "    # 原空间里降维后的数据\n",
    "    reconMat = (lowDataMat * redEigVects.T) + meanVals\n",
    "    return lowDataMat, reconMat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[10.235186, 11.321997],\n",
       "        [10.122339, 11.810993],\n",
       "        [ 9.190236,  8.904943],\n",
       "        [ 9.306371,  9.847394]])"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataMat = loadDataSet('testSet.txt')\n",
    "dataMat[:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1000, 2) (2, 1) (1000, 1)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(1000, 1)"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lowMat, reconMat = PCA(dataMat, 1)\n",
    "np.shape(lowMat)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 绘制出原始图像与降维后图像"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD8CAYAAACINTRsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJztnXl8VPW5/9/fmSQDJKEUDbuKCyJqrSJqS0Ur1roUt0K1lN5CK7ZysSrUpf68rXVri1oB9WovUkGLRRFstW4ErAuI0aIIRSGAyKbIpkhIMpPJzPf3x+QMk8k5c5bZk+f9euUFmTlz5sn2Oc95VqW1RhAEQWgf+PJtgCAIgpA5RNQFQRDaESLqgiAI7QgRdUEQhHaEiLogCEI7QkRdEAShHSGiLgiC0I4QURcEQWhHiKgLgiC0I0py+WYHH3yw7t+/fy7fUhAEoeh59913d2utq5wcm1NR79+/P8uXL8/lWwqCIBQ9SqnNTo+V8IsgCEI7QkRdEAShHSGiLgiC0I6wFXWl1KNKqZ1KqdUmz12vlNJKqYOzY54gCIL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O5RSvQFa/t2ZZ3vaNUqpscAIYIwuvnruvwEj7Q4qClHXWn8GbFVKDWx56Gzgwzya5IbRFEnopYUtwDeUUl2UUorY97qgk9IASqkeLf8eSiyBVyzf8+eAsS3/Hws8m0db2jVKqfOAm4CLtNYN+bbHCUkJ/4uAtbavKZaLlVLqRGAmUAZsBH6qtf4iv1alpiW+uxU4Qmv9Zb7tcYpS6jbgcmK3qCuA8VrrUH6tSo1SaglwEBAGJmutX8mzSW1QSs0Fvk1s8t4O4FbgH8A84FBiF9QfaK2Tk6l5xcLuz4EHgCpgL/C+1vrcfNmYjIXNNwMBYE/LYTVa66vyYqAJFjZfAAwEosQm3F7VkveyPk+xiLogCIJgT1GEXwRBEARniKgLgiC0I0TUBUEQ2hEi6oIgCO0IEXVBEIR2hIi6IAhCO0JEXRAEoR0hoi4IgtCO+P8BNm4Hyd2Q4QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x2be20404fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(111)\n",
    "ax.scatter(dataMat[:,0].flatten().A[0], dataMat[:,1].flatten().A[0], marker='^', s=90)\n",
    "ax.scatter(reconMat[:,0].flatten().A[0], reconMat[:,1].flatten().A[0], marker='o', s= 50, c='red')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 利用PCA对半导体制造数据降维\n",
    "将使用平均值来代替NaN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "def replaceNanWithMean(filename):\n",
    "    '''将NaN数据用均值代替'''\n",
    "    dataMat = loadDataSet(filename, ' ')\n",
    "    numFeat = np.shape(dataMat)[1]\n",
    "    for i in range(numFeat):\n",
    "        # 计算每个特征的均值\n",
    "        index = [i for i in range(np.shape(dataMat)[0])]\n",
    "        NanIndex = np.nonzero(np.isnan(dataMat[:,i].A))[0]\n",
    "        notNanIndex = [s for s in index if s not in NanIndex]\n",
    "        meanVal = np.mean(dataMat[notNanIndex,i])\n",
    "        dataMat[NanIndex, i] = meanVal\n",
    "    return dataMat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1567, 590)"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataMat = replaceNanWithMean('secom.data')\n",
    "np.shape(dataMat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 5.34151979e+07,  2.17466719e+07,  8.24837662e+06,  2.07388086e+06,\n",
       "        1.31540439e+06,  4.67693557e+05,  2.90863555e+05,  2.83668601e+05,\n",
       "        2.37155830e+05,  2.08513836e+05,  1.96098849e+05,  1.86856549e+05,\n",
       "        1.52422354e+05,  1.13215032e+05,  1.08493848e+05,  1.02849533e+05,\n",
       "        1.00166164e+05,  8.33473762e+04,  8.15850591e+04,  7.76560524e+04,\n",
       "        6.66060410e+04,  6.52620058e+04,  5.96776503e+04,  5.16269933e+04,\n",
       "        5.03324580e+04,  4.54661746e+04,  4.41914029e+04,  4.15532551e+04,\n",
       "        3.55294040e+04,  3.31436743e+04,  2.67385181e+04,  1.47123429e+04,\n",
       "        1.44089194e+04,  1.09321187e+04,  1.04841308e+04,  9.48876548e+03,\n",
       "        8.34665462e+03,  7.22765535e+03,  5.34196392e+03,  4.95614671e+03,\n",
       "        4.23060022e+03,  4.10673182e+03,  3.41199406e+03,  3.24193522e+03,\n",
       "        2.74523635e+03,  2.35027999e+03,  2.16835314e+03,  1.86414157e+03,\n",
       "        1.76741826e+03,  1.70492093e+03,  1.66199683e+03,  1.53948465e+03,\n",
       "        1.33096008e+03,  1.25591691e+03,  1.15509389e+03,  1.12410108e+03,\n",
       "        1.03213798e+03,  1.00972093e+03,  9.50542179e+02,  9.09791361e+02,\n",
       "        8.32001551e+02,  8.08898242e+02,  7.37343627e+02,  6.87596830e+02,\n",
       "        5.64452104e+02,  5.51812250e+02,  5.37209115e+02,  4.93029995e+02,\n",
       "        4.13720573e+02,  3.90222119e+02,  3.37288784e+02,  3.27558605e+02,\n",
       "        3.08869553e+02,  2.46285839e+02,  2.28893093e+02,  1.96447852e+02,\n",
       "        1.75559820e+02,  1.65795169e+02,  1.56428052e+02,  1.39671194e+02,\n",
       "        1.28662864e+02,  1.15624070e+02,  1.10318239e+02,  1.08663541e+02,\n",
       "        1.00695416e+02,  9.80687852e+01,  8.34968275e+01,  7.53025397e+01,\n",
       "        6.89260158e+01,  6.67786503e+01,  6.09412873e+01,  5.30974002e+01,\n",
       "        4.71797825e+01,  4.50701108e+01,  4.41349593e+01,  4.03313416e+01,\n",
       "        3.95741636e+01,  3.74000035e+01,  3.44211326e+01,  3.30031584e+01,\n",
       "        3.03317756e+01,  2.88994580e+01,  2.76478754e+01,  2.57708695e+01,\n",
       "        2.44506430e+01,  2.31640106e+01,  2.26956957e+01,  2.16925102e+01,\n",
       "        2.10114869e+01,  2.00984697e+01,  1.86489543e+01,  1.83733216e+01,\n",
       "        1.72517802e+01,  1.60481189e+01,  1.54406997e+01,  1.48356499e+01,\n",
       "        1.44273357e+01,  1.42318192e+01,  1.35592064e+01,  1.30696836e+01,\n",
       "        1.28193512e+01,  1.22093626e+01,  1.15228376e+01,  1.12141738e+01,\n",
       "        1.02585936e+01,  9.86906139e+00,  9.58794460e+00,  9.41686288e+00,\n",
       "        9.20276340e+00,  8.63791398e+00,  8.20622561e+00,  8.01020114e+00,\n",
       "        7.53391290e+00,  7.33168361e+00,  7.09960245e+00,  7.02149364e+00,\n",
       "        6.76557324e+00,  6.34504733e+00,  6.01919292e+00,  5.81680918e+00,\n",
       "        5.44653788e+00,  5.12338463e+00,  4.79593185e+00,  4.47851795e+00,\n",
       "        4.50369987e+00,  4.27479386e+00,  3.89124198e+00,  3.56466892e+00,\n",
       "        3.32248982e+00,  2.97665360e+00,  2.61425544e+00,  2.31802829e+00,\n",
       "        2.17171124e+00,  1.99239284e+00,  1.96616566e+00,  1.88149281e+00,\n",
       "        1.79228288e+00,  1.71378363e+00,  1.68028783e+00,  1.60686268e+00,\n",
       "        1.47158244e+00,  1.40656712e+00,  1.37808906e+00,  1.27967672e+00,\n",
       "        1.22803716e+00,  1.18531109e+00,  9.38857180e-01,  9.18222054e-01,\n",
       "        8.26265393e-01,  7.96585842e-01,  7.74597255e-01,  7.14002770e-01,\n",
       "        6.79457797e-01,  6.37928310e-01,  6.24646758e-01,  5.34605353e-01,\n",
       "        4.60658687e-01,  4.24265893e-01,  4.08634622e-01,  3.70321764e-01,\n",
       "        3.67016386e-01,  3.35858033e-01,  3.29780397e-01,  2.94348753e-01,\n",
       "        2.84154176e-01,  2.72703994e-01,  2.63265991e-01,  2.45227786e-01,\n",
       "        2.25805135e-01,  2.22331919e-01,  2.13514673e-01,  1.93961935e-01,\n",
       "        1.91647269e-01,  1.83668491e-01,  1.82518017e-01,  1.65310922e-01,\n",
       "        1.57447909e-01,  1.51263974e-01,  1.39427297e-01,  1.32638882e-01,\n",
       "        1.28000027e-01,  1.13559952e-01,  1.12576237e-01,  1.08809771e-01,\n",
       "        1.07136355e-01,  8.60839655e-02,  8.50467792e-02,  8.29254355e-02,\n",
       "        7.03701660e-02,  6.44475619e-02,  6.09866327e-02,  6.05709478e-02,\n",
       "        5.93963958e-02,  5.22163549e-02,  4.92729703e-02,  4.80022983e-02,\n",
       "        4.51487439e-02,  4.30180504e-02,  4.13368324e-02,  4.03281604e-02,\n",
       "        3.91576587e-02,  3.54198873e-02,  3.31199510e-02,  3.13547234e-02,\n",
       "        3.07226509e-02,  2.98354196e-02,  2.81949091e-02,  2.49158051e-02,\n",
       "        2.36374781e-02,  2.28360210e-02,  2.19602047e-02,  2.00166957e-02,\n",
       "        1.86597535e-02,  1.80415918e-02,  1.72261012e-02,  1.60703860e-02,\n",
       "        1.49566735e-02,  1.40165444e-02,  1.31296856e-02,  1.21358005e-02,\n",
       "        1.07166503e-02,  1.01045695e-02,  9.76055340e-03,  9.16740926e-03,\n",
       "        8.78108857e-03,  8.67465278e-03,  8.30918514e-03,  8.05104488e-03,\n",
       "        7.56152126e-03,  7.31508852e-03,  7.26347037e-03,  6.65728354e-03,\n",
       "        6.50769617e-03,  6.28009879e-03,  6.19160730e-03,  5.64130272e-03,\n",
       "        5.30195373e-03,  5.07453702e-03,  4.47372286e-03,  4.32543895e-03,\n",
       "        4.22006582e-03,  3.97065729e-03,  3.75292740e-03,  3.64861290e-03,\n",
       "        3.38915810e-03,  3.27965962e-03,  3.06633825e-03,  2.99206786e-03,\n",
       "        2.83586784e-03,  2.74987243e-03,  2.31066313e-03,  2.26782346e-03,\n",
       "        1.82206662e-03,  1.74955624e-03,  1.69305161e-03,  1.66624597e-03,\n",
       "        1.55346749e-03,  1.51278404e-03,  1.47296800e-03,  1.33617458e-03,\n",
       "        1.30517592e-03,  1.24056353e-03,  1.19823961e-03,  1.14381059e-03,\n",
       "        1.13027458e-03,  1.11081803e-03,  1.08359152e-03,  1.03517496e-03,\n",
       "        1.00164593e-03,  9.50024604e-04,  8.94981182e-04,  8.74363843e-04,\n",
       "        7.98497544e-04,  7.51612219e-04,  6.63964301e-04,  6.21097643e-04,\n",
       "        6.18098604e-04,  5.72611403e-04,  5.57509231e-04,  5.47002381e-04,\n",
       "        5.27195077e-04,  5.11487997e-04,  4.87787872e-04,  4.74249071e-04,\n",
       "        4.52367688e-04,  4.24431101e-04,  4.19119024e-04,  3.72489906e-04,\n",
       "        3.38125455e-04,  3.34002143e-04,  2.97951371e-04,  2.84845901e-04,\n",
       "        2.79038288e-04,  2.77054476e-04,  2.67962796e-04,  2.54815125e-04,\n",
       "        2.29230595e-04,  1.99245436e-04,  1.90381389e-04,  1.84497913e-04,\n",
       "        1.77415682e-04,  1.68160613e-04,  1.63992030e-04,  1.58025552e-04,\n",
       "        1.54226003e-04,  1.46890640e-04,  1.46097434e-04,  1.40079892e-04,\n",
       "        1.35736724e-04,  1.22704035e-04,  1.16752515e-04,  1.14080847e-04,\n",
       "        1.04252870e-04,  9.90265095e-05,  9.66039063e-05,  9.60766569e-05,\n",
       "        9.16166337e-05,  9.07003475e-05,  8.60212634e-05,  8.32654025e-05,\n",
       "        7.70526075e-05,  7.36470021e-05,  7.24998306e-05,  6.80209909e-05,\n",
       "        6.68682701e-05,  6.14500432e-05,  5.99843180e-05,  5.49918002e-05,\n",
       "        5.24646951e-05,  5.13403845e-05,  5.02336253e-05,  4.89288504e-05,\n",
       "        4.51104474e-05,  4.29823765e-05,  4.18869715e-05,  4.14341561e-05,\n",
       "        3.94822846e-05,  3.80307292e-05,  3.57776535e-05,  3.43901591e-05,\n",
       "        2.98089203e-05,  2.72388358e-05,  1.46846459e-05,  1.66549051e-05,\n",
       "        2.42608885e-05,  2.30962279e-05,  2.27807559e-05,  2.14440814e-05,\n",
       "        1.96208174e-05,  1.88276186e-05,  1.91217363e-05,  1.43753346e-05,\n",
       "        1.39779892e-05,  1.21760519e-05,  1.20295835e-05,  7.20354827e-06,\n",
       "        7.36188587e-06,  1.13426750e-05,  1.09258905e-05,  8.34247969e-06,\n",
       "        8.93991857e-06,  9.23630203e-06,  1.02782990e-05,  1.01021807e-05,\n",
       "        9.64538293e-06,  9.72678794e-06,  6.69282813e-06,  6.49477814e-06,\n",
       "        5.91044555e-06,  6.00244889e-06,  5.67034892e-06,  5.31392219e-06,\n",
       "        5.09342484e-06,  4.65422046e-06,  4.45482134e-06,  4.11265577e-06,\n",
       "        3.48065952e-06,  3.65202838e-06,  3.77558985e-06,  2.78847699e-06,\n",
       "        2.57492503e-06,  2.66299626e-06,  2.39210232e-06,  2.06298821e-06,\n",
       "        2.00824521e-06,  1.76373602e-06,  1.58273269e-06,  1.44003524e-06,\n",
       "        1.32211395e-06,  1.49813697e-06,  1.42489429e-06,  1.10002716e-06,\n",
       "        9.01008863e-07,  8.49881106e-07,  7.62521870e-07,  6.57641102e-07,\n",
       "        5.85636640e-07,  5.33937361e-07,  4.16077215e-07,  3.33765858e-07,\n",
       "        2.95575264e-07,  2.54744632e-07,  2.20144574e-07,  1.86314522e-07,\n",
       "        1.77370966e-07,  1.54794344e-07,  1.47331686e-07,  1.39738552e-07,\n",
       "        1.04110968e-07,  1.00786519e-07,  9.38635089e-08,  9.10853310e-08,\n",
       "        8.71546321e-08,  7.48338889e-08,  6.06817434e-08,  5.66479200e-08,\n",
       "        5.24576912e-08,  4.57020648e-08,  2.89942623e-08,  2.60449418e-08,\n",
       "        2.10987990e-08,  2.17618740e-08,  1.75542294e-08,  1.34637028e-08,\n",
       "        1.27167434e-08,  1.23258199e-08,  1.04987513e-08,  9.86367961e-09,\n",
       "        9.33428123e-09,  8.49421567e-09,  7.42189373e-09,  6.46870571e-09,\n",
       "        6.84633763e-09,  5.76455806e-09,  5.01137947e-09,  3.48686437e-09,\n",
       "        2.91267161e-09,  2.77880627e-09,  1.73093431e-09,  1.42391208e-09,\n",
       "        9.24976262e-10,  1.16455105e-09,  1.11815903e-09,  6.95072923e-10,\n",
       "        6.13291166e-10,  5.27572950e-10,  1.80003529e-10,  1.97062231e-10,\n",
       "        2.61924413e-10, -2.35986936e-15,  1.91829305e-15,  1.25030565e-16,\n",
       "       -7.04820952e-17, -5.30736004e-19,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        0.00000000e+00,  0.00000000e+00])"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "meanVals = np.mean(dataMat, axis=0)\n",
    "meanRemoved = dataMat - meanVals\n",
    "covMat = np.cov(meanRemoved, rowvar=0)\n",
    "eigVals, eigVects = np.linalg.eig(np.mat(covMat))\n",
    "eigVals"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 5.39940056e+03, -8.47962623e+02,  1.02671010e+01,\n",
       "        -2.45970944e+02, -4.54056644e+01,  0.00000000e+00,\n",
       "         1.03564561e+00,  2.06711581e-02, -2.85551522e-01,\n",
       "         1.00407200e-02,  4.44272605e-03,  3.98068760e-02,\n",
       "         2.47998369e+00,  0.00000000e+00, -1.44897714e+00,\n",
       "         3.87793769e+01, -1.01453262e+00,  1.11754192e-02,\n",
       "         3.61182659e+00, -1.44267691e-01,  3.17516741e-02,\n",
       "        -5.09795855e+02,  6.98863220e+02, -4.73080639e+03,\n",
       "        -3.18039770e+03,  1.41680786e+00,  1.29427875e+00,\n",
       "         9.83857370e+00,  1.38642601e+01, -9.27259954e-01,\n",
       "        -9.57569533e-02, -2.23368205e+00, -6.92190774e-01,\n",
       "        -3.36365399e+00, -1.53602287e+00, -8.59953771e-01,\n",
       "         1.53598942e+00, -7.94197886e-01, -1.38483632e+00,\n",
       "        -4.63705988e+00, -1.60547029e+01,  7.08057209e+00,\n",
       "         0.00000000e+00, -2.30107079e+01,  6.91845156e-01,\n",
       "         8.98647207e+00, -5.42286770e+00, -5.25663172e-01,\n",
       "         1.40920817e+00,  0.00000000e+00, -1.26150093e+01,\n",
       "        -2.27425256e+02,  0.00000000e+00,  5.95227528e-02,\n",
       "         9.80614664e-02, -4.71609502e+01,  7.78341770e-03,\n",
       "        -6.58111211e-03, -7.91114348e-02, -7.35093707e+01,\n",
       "        -1.61705852e+01,  6.68948470e-01,  5.08954380e+00,\n",
       "        -2.37636837e+01, -6.39383558e+00, -1.02290922e+01,\n",
       "        -3.68822173e-01, -5.20358828e+02,  1.03831167e+01,\n",
       "         0.00000000e+00, -9.26866736e-01, -5.74140503e-01,\n",
       "        -3.31536593e+00,  7.30327238e+00, -2.28965364e-01,\n",
       "         1.34011316e-01,  6.21155553e-02,  4.50642994e-02,\n",
       "         2.48914239e-01, -1.95750243e-01,  3.04933631e-02,\n",
       "         4.90286397e-02,  9.74207408e-02,  2.29095904e-01,\n",
       "         1.99260758e-02,  2.93000389e-04, -5.10734022e-02,\n",
       "         4.75309561e-02, -1.16262435e+02, -4.77025045e-02,\n",
       "         3.46788194e+02,  9.48262628e-02, -2.04932867e-03,\n",
       "         6.44210021e-04, -8.26705768e-05, -3.03601633e-04,\n",
       "         2.55782553e-01,  0.00000000e+00, -1.02541614e+00,\n",
       "        -2.71743856e-01,  7.97753078e-04, -3.79955732e-04,\n",
       "        -2.22687292e-01, -1.62419091e-02,  3.44150032e-03,\n",
       "         2.47360599e-03, -1.69411152e-03, -2.92634546e-02,\n",
       "        -1.10440894e-01, -2.42753307e-02,  2.05222566e+00,\n",
       "        -6.55770882e+00, -7.65697414e-02,  1.62350630e-02,\n",
       "        -9.03717721e-04,  8.37440448e+01,  3.96611388e-02,\n",
       "        -3.48835289e-01, -7.66715124e-03, -7.37046646e-03,\n",
       "         3.63872934e-02, -8.10590828e-02,  3.06940494e-03,\n",
       "        -1.58032951e-01, -2.48101418e-01,  6.52823418e-01,\n",
       "        -4.68105579e-01, -8.61824552e-02, -9.73688750e-01,\n",
       "        -6.13021951e+00,  7.62451439e-02,  4.21094239e-03,\n",
       "         1.21321576e-01, -3.80914855e+00,  2.57335192e+00,\n",
       "        -2.97932609e+02,  6.23780382e+02,  6.14098161e+02,\n",
       "        -1.96043109e+01,  3.31200526e+01, -4.11855553e+02,\n",
       "         0.00000000e+00, -1.94500050e+00, -1.44084731e-04,\n",
       "         1.07338766e-01, -4.75745112e-02, -5.09623037e-02,\n",
       "        -3.53618220e-02,  7.33939530e-01,  0.00000000e+00,\n",
       "         1.55762714e+00, -3.23473081e+01,  6.01531435e+00,\n",
       "        -2.08918261e-02, -3.63437137e+00,  4.02966929e-01,\n",
       "         2.40596028e-01, -2.01823852e-02,  1.57385831e+02,\n",
       "        -2.67175513e+03, -1.59839092e+02,  4.38586649e+03,\n",
       "         3.05346743e+04, -3.91238381e-01, -1.01649449e+00,\n",
       "        -1.63204234e+00,  1.75891139e-01,  1.37573767e+00,\n",
       "         5.33496192e-02,  7.26578500e-01, -7.44295565e-02,\n",
       "        -1.07899716e-01,  3.35919550e-02,  2.53900522e-01,\n",
       "         3.33521284e-02,  2.35626377e-01, -7.33078933e-02,\n",
       "        -8.95215186e-01,  0.00000000e+00,  0.00000000e+00,\n",
       "        -4.87893924e-01,  3.43225179e-02,  9.26869784e+00,\n",
       "        -1.18682296e+01,  4.20887603e-02, -3.59751063e+00,\n",
       "         0.00000000e+00, -8.22781152e+00, -7.42537315e+01,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         6.05234560e-01, -2.69669558e+01, -1.48234048e+01,\n",
       "        -9.21141245e-01, -2.02974036e+01, -1.90639189e+01,\n",
       "         4.21633122e-02, -1.87760831e+01, -3.19398644e+01,\n",
       "        -1.13844158e+03, -2.78097901e+01, -1.09148070e-01,\n",
       "        -3.75969972e+01, -7.92157357e+01, -2.51859171e+00,\n",
       "        -8.26618615e-03, -4.74641450e-02, -6.94059155e-02,\n",
       "        -1.08787615e-01,  1.08571160e-01, -3.05330931e-02,\n",
       "         1.05825310e-01, -9.01324444e-02, -7.21514513e-01,\n",
       "        -9.07670073e-03, -3.73161039e-03, -3.86914868e-03,\n",
       "        -9.72489176e-02, -9.38114685e+01, -7.17167743e-02,\n",
       "        -4.79004385e+02,  0.00000000e+00, -1.35037248e-02,\n",
       "        -1.14864626e-02,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00, -3.58331949e-03, -1.16809895e-03,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  2.06530110e-01,  8.35796150e+00,\n",
       "         2.20234036e+01, -1.41931974e-01, -4.17908558e-02,\n",
       "        -1.26943980e-02,  3.28171925e+01,  4.73405261e-04,\n",
       "        -2.00030729e+01, -1.91184918e-02,  5.58071559e-04,\n",
       "        -7.36572046e-01,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         1.76821635e-01, -1.31205689e+01,  2.95496767e+00,\n",
       "        -4.26744595e+01,  2.03861571e+02,  1.96888931e+02,\n",
       "        -3.59184822e+00,  2.99936366e+01, -1.37185724e+02,\n",
       "         0.00000000e+00, -5.43393730e-01, -4.29121378e-04,\n",
       "         3.34509249e-02, -8.12824284e-03, -1.02911851e-02,\n",
       "        -1.10959131e-02,  7.52226846e-01,  0.00000000e+00,\n",
       "         3.22089456e-02, -1.30126545e+01,  1.89995499e+00,\n",
       "        -6.58706153e-03, -7.69541477e-01,  1.08971580e-01,\n",
       "         7.92433580e-02, -5.70493415e-03,  3.59450423e+01,\n",
       "        -1.34765136e+03, -1.91924561e+02,  2.02027261e+03,\n",
       "         1.43868445e+04, -2.11905894e-01, -5.33134794e-01,\n",
       "        -8.44641355e-01, -1.48064489e-01,  4.60890725e-01,\n",
       "         1.21720252e-02,  2.67515828e-01,  3.22639186e-02,\n",
       "        -3.74142272e-02,  5.21608848e-03,  8.17481056e-02,\n",
       "         5.17196898e-03,  1.07927133e-01, -4.42375525e-02,\n",
       "        -3.83915511e-01,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  1.17018938e+00,  1.64682988e-02,\n",
       "         2.87206906e+00, -2.19826516e+00,  8.63654093e-03,\n",
       "        -1.08107187e+00,  0.00000000e+00, -1.01947863e+00,\n",
       "        -1.83054477e+01,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  1.14509129e-01, -9.33597599e+00,\n",
       "        -4.11314252e+00, -3.63448263e-01, -7.38385667e+00,\n",
       "        -1.28707881e+01, -5.32037993e-01, -9.21775938e+00,\n",
       "        -1.09667590e+01, -4.45903422e+02, -8.44568158e+00,\n",
       "        -2.44055084e-02, -1.00933447e+01, -2.41077698e+01,\n",
       "         8.50431247e-01, -1.95630127e+00, -7.59381324e-01,\n",
       "        -1.30931135e-02, -2.07705059e-02, -3.27229001e-02,\n",
       "        -5.52392247e-02,  2.08834826e-02, -1.35727773e-02,\n",
       "         6.20012678e-02, -4.57233103e-02, -6.59243602e-01,\n",
       "        -2.76040867e-03, -6.49140790e-04, -3.34631990e-03,\n",
       "        -3.52455211e-02, -2.83620894e+01, -2.31915786e-02,\n",
       "        -2.91866983e+02,  0.00000000e+00, -4.57321511e-03,\n",
       "        -3.89311402e-03, -1.89320685e-03, -1.65803152e-03,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00, -1.07915996e-03, -6.06713257e-05,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  6.52681925e-02,  2.69732373e+00,\n",
       "         7.00656950e+00, -2.05637675e-02, -1.82238932e-02,\n",
       "        -3.94709853e-03, -3.56802120e-01,  6.88922161e-04,\n",
       "        -6.48160330e+00, -3.09558158e-03,  4.62060332e-04,\n",
       "        -2.31657099e-01,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         6.15701467e-02, -5.53311285e+00,  9.56027367e-01,\n",
       "        -1.35679606e+01,  1.19452771e+01,  2.66211407e+01,\n",
       "        -9.09776216e-01,  1.03204184e+01, -7.80131881e+01,\n",
       "         0.00000000e+00, -2.30089555e+00, -8.15388796e-02,\n",
       "         9.04649969e+00, -4.26128132e+01,  3.92776252e+02,\n",
       "        -3.57891662e+00, -5.30841623e-01,  0.00000000e+00,\n",
       "         6.37930564e+01, -1.39028446e+01, -1.23331656e+01,\n",
       "        -2.09172936e+00, -1.86575982e+00,  3.64322613e+00,\n",
       "         1.84984035e+01, -1.48802743e+02, -1.10426321e+02,\n",
       "        -1.00340249e+02,  1.03798414e+03, -1.61165522e+02,\n",
       "        -1.65026704e+02, -1.64305055e+02, -6.99266880e-01,\n",
       "         6.65152648e+01,  9.07481375e+01,  2.30118073e+01,\n",
       "        -7.73972749e-02, -7.63626445e-01,  7.37214639e-02,\n",
       "         4.14975114e-01,  5.24054220e-02,  3.69039946e-01,\n",
       "        -8.23601671e-02, -7.24602948e-01,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  1.31664780e-01,\n",
       "         2.18926213e-01,  6.35478010e+00, -1.56679867e+00,\n",
       "         9.28577088e+00, -2.03651976e+00,  0.00000000e+00,\n",
       "        -1.21769958e+00,  3.84636445e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  1.34624260e+01,\n",
       "         9.12662644e+02, -4.15499962e+00, -9.80981566e+00,\n",
       "        -8.09907202e+00,  4.71915150e+01,  3.90195282e+01,\n",
       "         7.33101776e+00, -4.73243894e+00, -2.12127968e+01,\n",
       "        -2.34622690e+01, -1.09148070e+01, -5.53198003e+00,\n",
       "        -9.62742483e+01,  0.00000000e+00, -2.32655055e+02,\n",
       "         6.84930067e+02, -2.38624244e+02, -3.78036696e+02,\n",
       "        -6.96853548e+02,  1.47482832e+03,  1.10364828e+03,\n",
       "        -4.70901211e+02, -1.57705325e+01, -7.04354188e+00,\n",
       "        -3.37109916e+00, -1.41101495e-01, -1.15177787e+01,\n",
       "        -5.26810837e+00,  3.65147783e+00, -6.27303504e+00,\n",
       "         0.00000000e+00, -1.21751103e+03, -4.51002507e+02,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "        -1.72918341e+02, -4.49180967e+02,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         2.63180220e+01,  9.73079361e+00,  1.04772561e+01,\n",
       "        -3.35474244e+01, -4.92272279e+00,  1.07931437e+02,\n",
       "         1.84324952e+00,  3.00640118e-01, -6.61537669e+00,\n",
       "        -3.26854055e+00,  5.29344902e-04, -1.17184954e+01,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  0.00000000e+00,\n",
       "         0.00000000e+00,  0.00000000e+00,  7.39159077e+00,\n",
       "        -1.30927892e+00,  7.26461125e+00,  1.65306603e-02,\n",
       "        -4.03554334e-04, -1.05611024e-03, -1.47678982e+00,\n",
       "         6.88342122e-01,  9.30442878e+00, -2.03510553e+01,\n",
       "         1.88954910e+00, -2.52223717e+01, -1.41018112e+00,\n",
       "         7.47475329e-01, -1.34911137e+01, -7.03783372e-01,\n",
       "         7.23898947e+01, -6.33734613e+00, -1.51724873e+00,\n",
       "         1.79749054e-01,  6.12710714e-01,  1.53600652e-01,\n",
       "         5.29925694e+01, -4.88256624e+00, -6.50287157e-02,\n",
       "         1.03599475e+01,  2.23645499e-01,  3.95234181e+00,\n",
       "         9.15719240e-02,  3.99336720e+00,  3.40025951e+01,\n",
       "        -2.43717152e+01, -4.68310221e-01,  8.67420877e+01,\n",
       "        -3.77429990e-02,  3.00793567e+01,  3.48051557e-02,\n",
       "         1.64478992e+01,  7.89121873e+00, -1.09331087e-02,\n",
       "        -1.89295597e-02, -6.06612272e-03, -6.91104838e+01,\n",
       "         5.59782459e-05,  2.95975978e-02,  5.44044988e-03,\n",
       "         6.20003160e+00,  1.67426295e-02, -1.67440688e-02,\n",
       "        -5.93197815e-03,  2.87879850e+01]])"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.shape(covMat)\n",
    "covMat[:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "总方差： 90146058.64106826\n",
      "前20个特征的方差百分比：\n",
      "47.58 19.91 11.54 9.33 4.32 2.11 1.07 0.44 0.37 0.35 0.28 0.25 0.21 0.20 0.17 0.12 0.12 0.12 0.12 0.10 \n",
      "前20个特征累计方差百分比：\n",
      "47.58 67.49 79.03 88.36 92.69 94.80 95.87 96.30 96.67 97.02 97.30 97.56 97.77 97.97 98.14 98.26 98.38 98.50 98.61 98.72 "
     ]
    }
   ],
   "source": [
    "# 每个特征上的方差\n",
    "eye = np.eye(len(covMat), dtype=int)\n",
    "varArray = covMat * eye\n",
    "varArray = [varArray[i,i] for i in range(len(varArray))]\n",
    "varArr = sorted(varArray, reverse = True)\n",
    "sumVar = np.sum(np.array(varArr))\n",
    "print(\"总方差：\",sumVar)\n",
    "# 前20个特征上的方差\n",
    "varArr = [varArr[s] for s in range(20)]\n",
    "# 方差百分比\n",
    "varArrRate = [varArr[s]/sumVar*100 for s in range(20)]\n",
    "print(\"前20个特征的方差百分比：\")\n",
    "for i in range(20):\n",
    "    print(\"{:.2f}\".format(varArrRate[i]), end=\" \")\n",
    "# 方差累加\n",
    "Comsum =np.cumsum(varArr)\n",
    "# 累计方差百分比\n",
    "ComsumRate = [Comsum[s]/sumVar*100 for s in range(20)]\n",
    "print(\"\\n前20个特征累计方差百分比：\")\n",
    "for i in range(20):\n",
    "    print(\"{:.2f}\".format(ComsumRate[i]), end=\" \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD9CAYAAACsq4z3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAGEFJREFUeJzt3X2QVNWZx/Hvw8yAim+II6IoyDQa34IhU6zGXeOqGDAWmI0aU+pSUYNJNL4b3bIqlZhKypdojMZoYTQS4you6kqMRik0WpVSdDCKAq4gIiIEUPAVA87w7B/njo5t93TP9Mvte+/vU9XV3feeph8uzW/OnHv6XHN3REQk+QbEXYCIiFSHAl1EJCUU6CIiKaFAFxFJCQW6iEhKKNBFRFKiuZxGZrYceB/oAjrdvd3MdgJmAqOA5cCJ7r6hNmWKiEgpfemh/7u7H+Tu7dHzS4G57j4GmBs9FxGRmFQy5DIFmBE9ngEcV3k5IiLSX+UGugOPmtl8M5sWbRvm7qsBovtdalGgiIiUp6wxdOBQd19lZrsAc8zs5XLfIPoBMA1g8ODBX/7CF77QjzJFRLJr/vz5b7l7a6l2ZQW6u6+K7tea2f3AeGCNmQ1399VmNhxYW+S104HpAO3t7d7R0VHu30FERAAze72cdiWHXMxssJlt1/0YOBp4CZgNTI2aTQUe6F+pIiJSDeX00IcB95tZd/v/dve/mNmzwD1mdjqwAjihdmWKiEgpJQPd3ZcBYwtsfxs4shZFiYhI3+mboiIiKaFAFxFJCQW6iEhKKNBFRFIiGYF+551w881xVyEi0tCSEeizZsH118ddhYhIQ0tGoOdysGwZbNkSdyUiIg0rGYHe1gabNsGbb8ZdiYhIw0pGoOdy4X7p0njrEBFpYMkK9FdfjbcOEZEG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dALXXg6PzA/aRN9qN8Fhtaluh6ioZ4vAfMK7D7EzF4ws4fNbP+6Fhau6/qomc2Pruear5xjXA8nUfw/UpzHD2CYu6+G8EMc2KVAm0Y5jqcRfuMqpNRnoZbOjoaEbisyZNUIx+/fgDXuvqTI/jiPX780WqCXc+Hpsi5OXUtmti1wL3Ceu7+Xt/s5wjDCWOAG4H/rWRtwqLuPAyYBZ5nZYXn7G+H4DQQmA/9TYHfcx69cjXAcLwM6gTuLNCn1WaiVm4A24CBgNWFYI1/sxw/4Nr33zuM6fv3WaIFezoWnP2ljZs3ADvTvV75+MbMWQpjf6e735e939/fc/YPo8UNAi5ntXK/63H1VdL8WuJ/wq21PZV3cu8YmAc+5+5r8HXEfv8ia7mGo6H5tgTaxHsfoJOyxwMkeDfjmK+OzUBPuvsbdu9x9C3BLkfeN+/g1A/8BzCzWJq7jV4lGC/RyLjw9G+ieUXA88FixD3S1RWNutwKL3f3aIm127R7TN7PxhGP8dp3qG2xm23U/Jpw8eymv2WzgP6PZLgcD73YPL9RR0Z5RnMevh56fsanAAwXaPAIcbWZDoiGFo6NtNWdmE4FLgMnuvrFIm3I+C7Wqr+c5mW8Ued+4LzJ/FPCyu68stDPO41eRuM/K5t8IszBeIZwBvyzadjnhwwuwFeFX9aXAM8DoOtb2r4RfCxcAz0e3Y4DvAd+L2pwNLCSctX8a+Eod6xsdve8LUQ3dx69nfQbcGB3fF4H2Ov/7bkMI6B16bIvt+BF+sKwGPib0Gk8nnJOZCyyJ7neK2rYDv+vx2tOiz+FS4Dt1rG8pYfy5+zPYPetrN+Ch3j4LdarvjuiztYAQ0sPz64uef+7/ej3qi7bf3v2Z69G27sev2jd9U1REJCUabchFRET6SYEuIpISCnQRkZRQoIuIpIQCXUQkJRToIiIpoUAXEUkJBbqISEr8PyfRqrQDn8w1AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x2be245ed080>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 方差占比折线图\n",
    "x = list(range(len(varArrRate )))\n",
    "plt.plot(x, varArrRate ,color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 由上图可以大致看出，有7个左右的特征值的方差最大，因此我们可以降维到6或者7，保留主成分即可"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
